package books.ThinkingInJava.src.Chapter18;


import books.ThinkingInJava.src.Tools.FileKit;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class TestFile {


    public static void main(String[] args) throws IOException {
        File path = FileKit.getSourceDirectory(new File("D:\\Doc\\Test"));
//        File path = FileKit.getSourceDirectory( new File("D"));  不能直接访问到硬盘一级文件
        List<File> list = new FileKit().getDirectory(path);
//        Pattern pattern = Pattern.compile("\\d");
        Long size = 0l;
        for (File f : list) {
//            if (pattern.matcher(f.getName()).matches());     多加了一个分号，导致的严重错误
//            if (pattern.matcher(f.getName()).matches())
//            {
//                Output.println(pattern.matcher(f.getName()).matches());
//                Output.println(f.getName());
//                Output.println(f.getName());
            size += FileKit.getAttribute(f).size();
//            }
        }

//        Output.println("File total length = " + size);
//        FileInputStream fis = null;
//        try {
//            fis = new FileInputStream(path);
//            byte[] by = new byte[1024];
//            fis.read(by);
//            Output.println(new String(by));
//            fis.close();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

    }

}
